﻿Public Class FormJLCheck
    'Private WithEvents UcDigitalKeyboard1 As ucDigitalKeyboard
    'Dim txt As TextBox
    Public usr As String
    Dim objJlMst As New clsJlMst
    Dim objJlCheck As New clsJlCheck
    Dim update_status As String = "INSERT_TYPE"
    Dim en As entityJLCheck
    Dim _sys_id As String

    Public Property Sys_id As String
        Get
            Return _sys_id
        End Get
        Set(value As String)
            _sys_id = value
        End Set
    End Property
    Private Sub FormJLCheck_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        initForm()
        If _sys_id <> "" Then
            update_status = "UPDATE_TYPE"
            setContentBySysid()
        Else
            update_status = "INSERT_TYPE"
        End If
    End Sub

    Private Sub initForm()
        Dim TDate As String = Date.Now.ToShortDateString()
        date_prod.Text = TDate
        date_dj.Text = TDate
        Dim dtJl As DataTable = objJlMst.getList()
        cmb_jl_type.DisplayMember = "mst_value"
        cmb_jl_type.ValueMember = "mst_value"
        cmb_jl_type.DataSource = dtJl
        If dtJl.Rows.Count > 0 Then
            cmb_jl_type.SelectedIndex = 0
        End If
        txt_t10.Value = 0
        txt_t90.Value = 0
        txt_ml.Value = 0
        txt_mh.Value = 0
        txt_yd1.Value = 0
        txt_yd2.Value = 0
        txt_yd3.Value = 0
        txt_md.Value = 0
        rbOK_jl.Checked = True
        txt_note.Text = String.Empty
    End Sub

    Private Sub setContentBySysid()
        Dim dt As DataTable = objJlCheck.selectBySysid(_sys_id)
        If dt.Rows.Count > 0 Then
            Dim row As DataRow = dt.Rows(0)
            date_prod.Text = row("date_prod")
            date_dj.Text = row("date_dj")
            cmb_jl_type.Text = row("jl_type")
            txt_t10.Text = row("lh_t10")
            txt_t90.Text = row("lh_t90")
            txt_ml.Text = row("lh_ml")
            txt_mh.Text = row("lh_mh")
            txt_yd1.Text = row("yd1")
            txt_yd2.Text = row("yd2")
            txt_yd3.Text = row("yd3")
            txt_md.Text = row("jl_md")
            If row("check_result") = 1 Then
                rbOK_jl.Checked = True
            End If
            If row("check_result") = 0 Then
                rbNG_jl.Checked = True
            End If
            txt_note.Text = row("note")

        End If
    End Sub

    'Private Sub txt_MouseDown(sender As Object, e As MouseEventArgs) Handles txt_medium_paint_curing_agent_count.MouseDown,
    '    SpinEdit4.MouseDown, SpinEdit5.MouseDown, SpinEdit6.MouseDown
    '    UcDigitalKeyboard1 = New ucDigitalKeyboard
    '    If sender.MaskBox.Mask.EditMask = "d" Then
    '        UcDigitalKeyboard1.B_01 = False
    '    Else
    '        UcDigitalKeyboard1.B_01 = True
    '    End If

    '    If sender.GetType().Name.Equals("TextEdit") Then
    '        UcDigitalKeyboard1.B_02 = True
    '    Else
    '        UcDigitalKeyboard1.B_02 = False
    '    End If

    '    UcDigitalKeyboard1.Txt = sender

    '    Me.Controls.Add(UcDigitalKeyboard1)
    '    UcDigitalKeyboard1.Show()
    '    UcDigitalKeyboard1.BringToFront()
    '    UcDigitalKeyboard1.Focus()
    'End Sub

    'Private Sub txt_MouseClick(sender As Object, e As MouseEventArgs)
    '    txt = CType(sender, TextBox)
    '    DateNavigator1.Left = txt.Left
    '    DateNavigator1.Top = txt.Location.Y + txt.Height
    '    DateNavigator1.Visible = True
    'End Sub

    'Private Sub DateNavigator1_DateTimeChanged(sender As Object, e As EventArgs)
    '    txt.Text = DateNavigator1.DateTime.ToShortDateString()
    '    DateNavigator1.Visible = False
    'End Sub

    Private Sub setEntity()
        en = New entityJLCheck
        With en
            .sys_id = _sys_id
            .factory_id = "TS"
            .date_prod = date_prod.Text
            .date_dj = date_dj.Text
            .jl_type = cmb_jl_type.Text
            .lh_t10 = txt_t10.Text
            .lh_t90 = txt_t90.Text
            .lh_ml = txt_ml.Text
            .lh_mh = txt_mh.Text
            .yd1 = txt_yd1.Text
            .yd2 = txt_yd2.Text
            .yd3 = txt_yd3.Text
            .jl_md = txt_md.Text
            .check_result = IIf(rbOK_jl.Checked = True, "1", "0")
            .note = txt_note.Text
            .oper = usr
        End With
    End Sub
    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If String.IsNullOrEmpty(date_prod.Text.Trim()) Then
            MsgBox("请选择生产日期", vbYes, "提示")
            Exit Sub
        End If
        If String.IsNullOrEmpty(date_dj.Text.Trim()) Then
            MsgBox("请选择打胶日期", vbYes, "提示")
            Exit Sub
        End If
        setEntity()
        If update_status = "INSERT_TYPE" Then
            If objJlCheck.insert(en) <> -2 Then
                MsgBox("保存成功", vbYes, "提示")
                initForm()
            Else
                MsgBox("保存失败", vbYes, "提示")
            End If
        End If
        If update_status = "UPDATE_TYPE" Then
            If objJlCheck.update(en) <> -2 Then
                MsgBox("保存成功", vbYes, "提示")
                CType(Owner, FormJLCheckRecord).setDgvData()
                Close()
            Else
                MsgBox("保存失败", vbYes, "提示")
            End If
        End If
    End Sub
End Class


Public Class entityJLCheck
    Public sys_id As String
    Public factory_id As String
    Public date_prod As String '生产日期
    Public date_dj As String '打胶日期
    Public jl_type As String '胶料型号
    Public lh_t10 As String 'T10/min
    Public lh_t90 As String 'T90/min
    Public lh_ml As String 'ML/dNm
    Public lh_mh As String 'MH/dNm
    Public yd1 As String '硬度/邵氏A
    Public yd2 As String '硬度/邵氏A
    Public yd3 As String '硬度/邵氏A
    Public jl_md As String '密度g/cm³
    Public check_result As String '检测结论
    Public note As String '工艺意见
    Public oper As String '确认人
End Class